//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "FormInRep.h"
#include "DataModule.h"
#include <DateUtils.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FR_Class"
#pragma link "FR_Ctrls"
#pragma link "FR_View"
#pragma link "FR_DBSet"
#pragma link "FR_DSet"
#pragma resource "*.dfm"
TFRepIncome *FRepIncome;
//---------------------------------------------------------------------------
__fastcall TFRepIncome::TFRepIncome(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::Prepear()
{
 // Eanble
 frSpeedButton1->Enabled = true;
 frSpeedButton2->Enabled = true;
 frSpeedButton3->Enabled = true;
 frSpeedButton4->Enabled = true;
 frSpeedButton5->Enabled = true;
 frSpeedButton6->Enabled = true;
 frSpeedButton7->Enabled = true;
 frSpeedButton10->Enabled = true;
 // set Sqls for reports
 if(AskIncom->Active)
  AskIncom->Close();
 AskIncom->SQL->Text = "select C.NAME AS CNAME, ART, P.NAME AS PNAME, D.CNT as CNT, D.PRICE as PRC, D.CNT * D.PRICE as PRICE from INPROD D INNER JOIN PRODUCT P ON P.IDPRODUCT = D.IDPRODUCT INNER JOIN CAT C on C.IDCAT = P.IDCAT where  IDIN = " +
 IDIN +  " ORDER BY C.NAME, P.ART";
 RepIn->PrepareReport();
 RepIn->ShowPreparedReport();
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton2Click(TObject *Sender)
{
 fP->Zoom = 100;
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton1Click(TObject *Sender)
{
 fP->OnePage();
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton3Click(TObject *Sender)
{
 fP->PageWidth();
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton4Click(TObject *Sender)
{
 fP->First();
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton5Click(TObject *Sender)
{
 fP->Prev();          
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton6Click(TObject *Sender)
{
 fP->Next();           
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton7Click(TObject *Sender)
{
 fP->Last();
}
//---------------------------------------------------------------------------
void __fastcall TFRepIncome::frSpeedButton10Click(TObject *Sender)
{
 fP->Print();            
}
//---------------------------------------------------------------------------








void __fastcall TFRepIncome::RepInUserFunction(const AnsiString Name,
      Variant &p1, Variant &p2, Variant &p3, Variant &Val)
{
 if(Name == "BEG")
  Val = Dt;        
}
//---------------------------------------------------------------------------

void __fastcall TFRepIncome::ApplicationEvents1Message(tagMSG &Msg,
      bool &Handled)
{
 if(Msg.message == WM_KEYDOWN)
 {
  if(Msg.wParam == 122)
  {
   frSpeedButton10Click(NULL);
   Handled = true;
  }
 }

}
//---------------------------------------------------------------------------


